package com.anders.springcloud.service;

import com.anders.springcloud.pojo.Dept;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class DeptClientServiceFallBackFactory implements FallbackFactory<DeptClientService> {
    @Override
    public DeptClientService create(Throwable throwable) {
        return new DeptClientService() {
            @Override
            public Dept queryById(long id) {
                return new Dept()
                        .setDeptno(id)
                        .setName("不存在")
                        .setDbSource("不存在");
            }

            @Override
            public List<Dept> queryAll() {
                return new ArrayList<>();
            }

            @Override
            public boolean addDept(Dept dept) {
                return false;
            }
        };
    }
}
